package com.example.zhuyu.basemvp.utils;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;

import com.example.zhuyu.basemvp.view.LoadingDialogFragment;

/**
 * @desc loading
 * @author zhuyu
 * @date
 */
public class CommonDialogUtil {
    private final LoadingDialogFragment mFragment;
    private Context context;

    public CommonDialogUtil(Context context) {
        this.context = context;
        mFragment = new LoadingDialogFragment();
    }

    public void showProgress() {
        Util.checkNullException(mFragment, "Please check LoadingDialogFragment is create");
        mFragment.show(((Activity) context).getFragmentManager());
    }

    public void showProgress(String loadMsg) {
        Util.checkNullException(mFragment, "Please check LoadingDialogFragment is create");
        Bundle bundle = new Bundle();
        bundle.putString("msg", loadMsg);
        mFragment.setArguments(bundle);
        mFragment.show(((Activity) context).getFragmentManager());
    }

    public void dismissProgress() {
        Util.checkNullException(mFragment, "Please check LoadingDialogFragment is create");
        mFragment.hide();
    }
}
